package com.bmw.bingfa.service.impl;

import com.bmw.bingfa.dao.TicketUserDao;
import com.bmw.bingfa.model.TicketUser;
import com.bmw.bingfa.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * Classname: UserServiceImpl
 * Package: com.bmw.bingfa.service.impl
 * Description:
 *
 * @Author 余集楠
 * @Create 2024/5/30 0030 16:17
 * @Version 1.8
 */
@Service("userService")
@Slf4j
public class UserServiceImpl implements UserService {
    @Autowired
    TicketUserDao ticketUserDao;
    @Override
    public TicketUser findByPhone(String phone) {
        Assert.notNull(phone);

        TicketUser ticketUser=new TicketUser();
        ticketUser.setPhone(phone);
        List<TicketUser>list=ticketUserDao.list(ticketUser);
        if(!CollectionUtils.isEmpty(list)){
             Assert.isTrue(list.size()==1);
             return list.get(0);
        }
        return null;
    }


}
